﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BG.DAL.Model;
using BG.DAL.Context;
using System.Data;

namespace BG.DAL.SQLDAL
{
    class FileAttachManager
    {
        public static FileAttach GetById(Guid id)
        {
            using (DataContext db = new DataContext())
            {
                FileAttach model = db.FileAttaches.Find(id);
                return model;
            }
        }

        public static void Create(FileAttach model)
        {
            using (DataContext db = new DataContext())
            {
                db.FileAttaches.Add(model);
                db.SaveChanges();
            }
        }

        public static void Edit(FileAttach model)
        {
            using (DataContext db = new DataContext())
            {
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
            }
        }

        public static void Delete(Guid id)
        {
            using (DataContext db = new DataContext())
            {
                FileAttach model = db.FileAttaches.Find(id);
                db.FileAttaches.Remove(model);
                db.SaveChanges();
            }
        }
    }
}
